/*******************************************************************************
 * SVN­Versioning-Information:
 * ­­­­­­­­­­­­­­­­­­­­­­­­
 * $LastChangedRevision: 128 $
 * $LastChangedBy: SD $
 * $LastChangedDate: 2009-06-23 12:33:08 +0200 (Tue, 23 Jun 2009) $
 * $HeadURL: svn://lvis10.fbm.fht-stuttgart.de/common/Common/src/de/hft_stuttgart/botwar/common/commands/MoveCmd.java $
 ******************************************************************************/
package de.hft_stuttgart.botwar.common.commands;

import de.hft_stuttgart.botwar.common.models.Position;

/**
 * Represents the command of moving a robot
 * @author Captain Code
 */
public final class MoveCmd extends Cmd {

    private final Position target;
    private final Integer robotID;

    /**
     * New move command.
     * @param target The TARGET to move the robot to
     * @param robotID The ID of the robot to move
     */
    public MoveCmd(final Position target, final Integer robotID) {
        this.target = target;
        this.robotID = robotID;
    }

    /**
     * Returns a target.
     * @return target position of this move command
     */
    public Position getTarget() {
        return target;
    }

    /**
     * Returns the robotID
     * @return robotID of this command
     */
    public Integer getRobotID() {
        return robotID;
    }

    /**
     * Overrides the method equals.
     * @param obj object to compare
     * @return boolean true or false
     */
    @Override
    public boolean equals(final Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final MoveCmd other = (MoveCmd) obj;
        if (this.target != other.target && (this.target == null ||
                !this.target.equals(other.target))) {

            return false;
        }
        if (this.robotID != other.robotID && (this.robotID == null ||
                !this.robotID.equals(other.robotID))) {

            return false;
        }
        return true;
    }

    /**
     * Overrides method toString.
     * @return getTarget() as String
     */
    @Override
    public String toString() {
        return String.format("Robot %d has new target: %s", getRobotID(),
                getTarget());
    }
}
